export {}

// Exclude 排除相同的
type Exclude<T, U> = T extends U ? never : T;
type R4 = Exclude<'a'|'b'|'c'|'d',  'a'|'b'|'c'> // type R4 = "d"

// Extract 提取相同的
type Extract<T, U> = T extends U ? T : never;
type R5 = Extract<'a'|'b'|'c'|'d',  'a'|'b'|'c'> // type R5 = "a" | "b" | "c"

// NonNullable 排除 null 和 undefined
type NonNullable<T> = T extends null | undefined ? never : T;
type R6 = NonNullable<'a' | null | undefined> // type R6 = "a"



// ReturnType 获取函数返回值类型
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
function fn(a: string, b: number, c: string[]) {
  return {name: 'zf', age: 10}
}
type GetUser = typeof fn
// type GetUser = () => {
//   name: string;
//   age: number;
// }
type ResType = ReturnType<GetUser>
// type ResType = {
//   name: string;
//   age: number;
// }



// Parameters<T> 获取函数参数类型 (元组)
type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never;
type ArgsType = Parameters<GetUser> // type ArgsType = [a: string, b: number, c: string[]]



// ConstructorParamters 获取构造函数的参数类型
